home *** CD-ROM | disk | FTP | other *** search
/ PCMania 56 / PCMania CD56_1.iso / abc.z / ORGCHART.FRM < prev    next >
Text File  |  1996-12-16  |  26KB  |  755 lines

  1. VERSION 4.00
  2. Begin VB.Form OrgChartDlg 
  3.    Appearance      =   0  'Flat
  4.    BackColor       =   &H00C0C0C0&
  5.    BorderStyle     =   1  'Fixed Single
  6.    Caption         =   "Organization Chart DEMO"
  7.    ClientHeight    =   1815
  8.    ClientLeft      =   465
  9.    ClientTop       =   1755
  10.    ClientWidth     =   5535
  11.    FillColor       =   &H00C0C0C0&
  12.    FillStyle       =   0  'Solid
  13.    BeginProperty Font 
  14.       name            =   "MS Sans Serif"
  15.       charset         =   0
  16.       weight          =   700
  17.       size            =   8.25
  18.       underline       =   0   'False
  19.       italic          =   0   'False
  20.       strikethrough   =   0   'False
  21.    EndProperty
  22.    ForeColor       =   &H80000008&
  23.    Height          =   2220
  24.    Icon            =   "ORGCHART.frx":0000
  25.    Left            =   405
  26.    LinkTopic       =   "Form1"
  27.    MaxButton       =   0   'False
  28.    ScaleHeight     =   1815
  29.    ScaleWidth      =   5535
  30.    Top             =   1410
  31.    Width           =   5655
  32.    Begin VB.CommandButton OptionsBtn 
  33.       Appearance      =   0  'Flat
  34.       BackColor       =   &H80000005&
  35.       Caption         =   "Options..."
  36.       Height          =   375
  37.       Left            =   4080
  38.       TabIndex        =   5
  39.       Top             =   720
  40.       Width           =   1335
  41.    End
  42.    Begin VB.CommandButton CancelBtn 
  43.       Appearance      =   0  'Flat
  44.       BackColor       =   &H80000005&
  45.       Caption         =   "Cancel"
  46.       Height          =   375
  47.       Left            =   2820
  48.       TabIndex        =   4
  49.       Top             =   1320
  50.       Width           =   1335
  51.    End
  52.    Begin VB.CommandButton BrowseBtn 
  53.       Appearance      =   0  'Flat
  54.       BackColor       =   &H80000005&
  55.       Caption         =   "Browse..."
  56.       Height          =   375
  57.       Left            =   4080
  58.       TabIndex        =   3
  59.       Top             =   240
  60.       Width           =   1335
  61.    End
  62.    Begin VB.CommandButton OKBtn 
  63.       Appearance      =   0  'Flat
  64.       BackColor       =   &H80000005&
  65.       Caption         =   "OK"
  66.       Default         =   -1  'True
  67.       Enabled         =   0   'False
  68.       Height          =   375
  69.       Left            =   1320
  70.       TabIndex        =   2
  71.       Top             =   1320
  72.       Width           =   1335
  73.    End
  74.    Begin VB.TextBox OrgChartTextFileEdit 
  75.       Appearance      =   0  'Flat
  76.       BackColor       =   &H00FFFFFF&
  77.       BeginProperty Font 
  78.          name            =   "MS Sans Serif"
  79.          charset         =   0
  80.          weight          =   400
  81.          size            =   8.25
  82.          underline       =   0   'False
  83.          italic          =   0   'False
  84.          strikethrough   =   0   'False
  85.       EndProperty
  86.       Height          =   285
  87.       Left            =   120
  88.       TabIndex        =   1
  89.       Top             =   600
  90.       Width           =   3675
  91.    End
  92.    Begin MSComDlg.CommonDialog OrgChartBrowse 
  93.       Left            =   360
  94.       Top             =   1320
  95.       _Version        =   65536
  96.       _ExtentX        =   847
  97.       _ExtentY        =   847
  98.       _StockProps     =   0
  99.    End
  100.    Begin AbcflowLib.ABC ABC1 
  101.       Height          =   375
  102.       Left            =   4560
  103.       TabIndex        =   6
  104.       Top             =   1320
  105.       Width           =   495
  106.       _version        =   65536
  107.       _extentx        =   873
  108.       _extenty        =   661
  109.       _stockprops     =   1
  110.    End
  111.    Begin VB.Line Line6 
  112.       BorderColor     =   &H00808080&
  113.       X1              =   0
  114.       X2              =   5520
  115.       Y1              =   1800
  116.       Y2              =   1800
  117.    End
  118.    Begin VB.Line Line5 
  119.       BorderColor     =   &H00808080&
  120.       X1              =   5520
  121.       X2              =   5520
  122.       Y1              =   1800
  123.       Y2              =   0
  124.    End
  125.    Begin VB.Line Line4 
  126.       BorderColor     =   &H00FFFFFF&
  127.       X1              =   5520
  128.       X2              =   0
  129.       Y1              =   0
  130.       Y2              =   0
  131.    End
  132.    Begin VB.Line Line3 
  133.       BorderColor     =   &H00FFFFFF&
  134.       X1              =   0
  135.       X2              =   0
  136.       Y1              =   1800
  137.       Y2              =   0
  138.    End
  139.    Begin VB.Line Line2 
  140.       BorderColor     =   &H00FFFFFF&
  141.       X1              =   0
  142.       X2              =   5520
  143.       Y1              =   1210
  144.       Y2              =   1210
  145.    End
  146.    Begin VB.Line Line1 
  147.       BorderColor     =   &H00808080&
  148.       X1              =   0
  149.       X2              =   5520
  150.       Y1              =   1200
  151.       Y2              =   1200
  152.    End
  153.    Begin VB.Label Label1 
  154.       Appearance      =   0  'Flat
  155.       BackColor       =   &H00C0C0C0&
  156.       Caption         =   "ASCII Text File:"
  157.       ForeColor       =   &H80000008&
  158.       Height          =   255
  159.       Left            =   120
  160.       TabIndex        =   0
  161.       Top             =   360
  162.       Width           =   2055
  163.    End
  164. End
  165. Attribute VB_Name = "OrgChartDlg"
  166. Attribute VB_Creatable = False
  167. Attribute VB_Exposed = False
  168. Dim ABC As Object
  169. Dim FormatIter As Integer
  170. Dim LoopIter As Integer
  171. Dim TotalFormatIter As Integer
  172. Dim req_objs As Integer
  173.  
  174. Private Sub ABC1_AppQuitNOTIFY()
  175.     End
  176. End Sub
  177.  
  178. Private Sub BrowseBtn_Click()
  179.     OrgChartBrowse.Action = 1
  180.    ' OrgChartBrowse.Filename = OrgChartTextFileEdit.Text
  181.     OrgChartTextFileEdit.Text = LCase(OrgChartBrowse.Filename)
  182.     OrgChartBrowse.Filename = "*.txt"
  183. End Sub
  184.  
  185. Private Function CalcPercent() As Integer
  186.     CalcPercent = 100 * ((LoopIter / req_objs) / TotalFormatIter + (FormatIter - 1) / TotalFormatIter) + 1
  187.     If CalcPerent > 100 Then CalcPercent = 100
  188.     If CalcPerent < 0 Then CalcPercent = 0
  189.  
  190.     LoopIter = LoopIter + 1
  191. End Function
  192.  
  193. Private Sub CancelBtn_Click()
  194.     Unload OrgChartDlg
  195. End Sub
  196.  
  197. Private Sub Command2_Click()
  198.     OrgChartBrowse.Action = 1
  199. End Sub
  200.  
  201. Private Function DoCreateOrgChart(ByVal Filename As String) As Integer
  202.     Dim OrgItem As String
  203.    
  204.     Dim Chart As Object
  205.     Dim cur_pos As Integer
  206.     Dim len_str As Integer
  207.  
  208.     Rem Make a new chart
  209.     Set Chart = ABC.New
  210.  
  211.     Rem Set the right shape palette
  212.     Chart.CurrentShapePalette = "Standard"
  213.     Chart.CurrentShape = "Process"
  214.     ABC.ShapePaletteVisible = False
  215.  
  216.     Rem Set the Chart's internal type
  217.     Chart.Type = "PROCESS"
  218.  
  219.     Rem Turn off master items
  220.     Chart.MasterItems.Hideall
  221.  
  222.     Chart.DrawDirection = 2
  223.     Chart.DrawPositionX = 4
  224.     Chart.DrawPositionY = 1
  225.     Chart.DrawSpacingY = 0.25
  226.     Chart.CurrentLineRouting = 3
  227.  
  228.     If OrgChartOptionsDlg.TopToBottomRBtn.Value = True Or OrgChartOptionsDlg.BottomToTopRBtn = True Then
  229.         vertical = True
  230.     Else
  231.         vertical = False
  232.     End If
  233.  
  234.     If OrgChartOptionsDlg.BottomToTopRBtn.Value = True Or OrgChartOptionsDlg.RightToLeftRBtn = True Then
  235.         inverted = True
  236.     Else
  237.         inverted = False
  238.     End If
  239.  
  240.     If vertical Then
  241.         Chart.PageLayout.Orientation = 1
  242.     Else
  243.         Chart.PageLayout.Orientation = 0
  244.     End If
  245.  
  246.     Chart.NoRepaint = True
  247.  
  248.  
  249.     len_file = FileLen(Filename)
  250.     If len_file < 32767 And len_file > 0 Then
  251.  
  252.         Dim EntireFile As String
  253.         Dim test_ascCode As Integer
  254.         Dim rank As Integer
  255.         Dim index As Integer
  256.         Dim cur_obj_count As Integer
  257.         Dim num_levels As Integer
  258.  
  259.         Open Filename For Binary Access Read As #1
  260.         EntireFile = String$(len_file, " ")
  261.         Get #1, , EntireFile
  262.         Close
  263.  
  264.         Rem Set up the progess bar
  265.         ABC.PercentGauge "Organization Chart DEMO", "PASS 1 of 2: Reading & parsing file..."
  266.         DrawnCount = 0
  267.  
  268.         req_objs = GetNumLines(EntireFile) + 1
  269.  
  270.         ReDim ShapeList(req_objs) As Object
  271.         ReDim ShapeRefStack(req_objs) As Integer
  272.         ReDim RelationMap(req_objs, 3) As Integer
  273.         Const first_child = 1, next_sibling = 2, parent = 3
  274.                                                  
  275.         cur_pos = 1
  276.         index = 2
  277.         cur_obj_count = 1
  278.         ShapeRefStack(1) = 1
  279.  
  280.         Do While cur_pos < len_file + 1
  281.             test_ascCode = Asc(Mid$(EntireFile, cur_pos, 1))
  282.             rank = 2
  283.             While test_ascCode <> 13 And test_ascCode <> 10 And cur_pos < len_file + 1
  284.                 If test_ascCode = 9 Then
  285.                     rank = rank + 1
  286.                 Else
  287.                     OrgItem = OrgItem + Chr$(test_ascCode)
  288.                 End If
  289.                 cur_pos = cur_pos + 1
  290.                 test_ascCode = Asc(Mid$(EntireFile, cur_pos, 1))
  291.             Wend
  292.             cur_pos = cur_pos + 1
  293.  
  294.             OrgItem = FormatOrgString(OrgItem)
  295.  
  296.             If rank > num_levels Then
  297.                 num_levels = rank
  298.             End If
  299.  
  300.             If Len(OrgItem) > 0 Then
  301.                 If rank > index Then
  302.                     index = index + 1
  303.                 ElseIf rank < index Then
  304.                     index = rank
  305.                 End If
  306.                 
  307.                 Chart.DrawPositionX = 1 + (index)
  308.                 Chart.DrawPositionY = 2
  309.  
  310.                 cur_obj_count = cur_obj_count + 1
  311.  
  312.                 Set ShapeList(cur_obj_count) = Chart.DrawShape("Process")
  313.                 ShapeList(cur_obj_count).Text = OrgItem
  314.  
  315.                 Rem update status bar
  316.                 DrawnCount = DrawnCount + 1
  317.                 ABC.PercentGaugeValue = 100 * DrawnCount / (req_objs - 1)
  318.                 
  319.  
  320.                 'Give all the shapes some attributes here
  321.                 ShapeList(cur_obj_count).Shape.FillColor = ABC.YELLOW
  322.                 ShapeList(cur_obj_count).Shape.BorderColor = ABC.BLUE
  323.                 ShapeList(cur_obj_count).Shape.ShadowStyle = 1
  324.                 ShapeList(cur_obj_count).Shape.NumberShown = False
  325.                 ShapeList(cur_obj_count).Shape.BorderWidth = 3
  326.                 ShapeList(cur_obj_count).Shape.FitShapeToText
  327.  
  328.  
  329.  
  330.                 ShapeRefStack(index) = cur_obj_count
  331.  
  332.                 RelationMap(cur_obj_count, parent) = ShapeRefStack(index - 1)
  333.                 RelationMap(cur_obj_count, next_sibling) = RelationMap(RelationMap(cur_obj_count, parent), first_child)
  334.                 RelationMap(RelationMap(cur_obj_count, parent), first_child) = cur_obj_count
  335.                 RelationMap(cur_obj_count, first_child) = 0
  336.                 
  337.                 OrgItem = ""
  338.             End If
  339.             If ABC.PercentGaugeCancelled Then Exit Do
  340.         Loop
  341.         
  342.         If ABC.PercentGaugeCancelled Then GoTo DoCreateAbort
  343.  
  344.         ABC.PercentGauge "Organization Chart DEMO", "PASS 2 of 2: Formatting chart..."
  345.  
  346.         Rem There are currently five iterations of formatting
  347.         TotalFormatIter = 5
  348.         FormatIter = 0
  349.         
  350.         'We need to go through the list and make sure
  351.         'the sizes work according to the Options Dlg
  352.         Const size_cx = 1, size_cy = 2
  353.         Dim finished As Integer
  354.         ReDim obj_size_level(req_objs, 2) As Double
  355.         Dim counter As Integer
  356.  
  357.         finished = False
  358.         cur_obj_count = 1
  359.         index = 1
  360.         Call NewGaugeLoop
  361.  
  362.         'Here we traverse the tree gathering the maximum size box in each level
  363.         While Not ABC.PercentGaugeCancelled And Not finished
  364.             Rem update status bar
  365.             ABC.PercentGaugeValue = CalcPercent()
  366.  
  367.             If cur_obj_count <> 1 Then
  368.                 If ShapeList(cur_obj_count).Height > obj_size_level(index, size_cy) Then
  369.                     obj_size_level(index, size_cy) = ShapeList(cur_obj_count).Height
  370.                 End If
  371.  
  372.                 If ShapeList(cur_obj_count).Width > obj_size_level(index, size_cx) Then
  373.                     obj_size_level(index, size_cx) = ShapeList(cur_obj_count).Width
  374.                 End If
  375.             End If
  376.             If RelationMap(cur_obj_count, first_child) = 0 Then
  377.                 ShapeRefStack(index) = cur_obj_count
  378.  
  379.                 cur_obj_count = RelationMap(cur_obj_count, next_sibling)
  380.  
  381.                 While cur_obj_count = 0 And index <> 1
  382.                     index = index - 1
  383.                     If index > 1 Then
  384.                         cur_obj_count = ShapeRefStack(index)
  385.                         If cur_obj_count Then
  386.                             cur_obj_count = RelationMap(cur_obj_count, next_sibling)
  387.                         End If
  388.                     End If
  389.                 Wend
  390.             Else
  391.                 ShapeRefStack(index) = cur_obj_count
  392.                 index = index + 1
  393.                 cur_obj_count = RelationMap(cur_obj_count, first_child)
  394.             End If
  395.             If index = 1 Then
  396.                 finished = True
  397.             End If
  398.         Wend
  399.         
  400.         'Now we have to adjust if the manager's size increases.
  401.         If OrgChartOptionsDlg.IncreaseMgrSize.Value = True Then
  402.             For counter = num_levels - 1 To 2 Step -1
  403.                 If obj_size_level(counter, size_cx) < obj_size_level(counter + 1, size_cx) Then
  404.                     obj_size_level(counter, size_cx) = obj_size_level(counter + 1, size_cx)
  405.                 End If
  406.                 If obj_size_level(counter, size_cy) < obj_size_level(counter + 1, size_cy) Then
  407.                     obj_size_level(counter, size_cy) = obj_size_level(counter + 1, size_cy)
  408.                 End If
  409.             Next
  410.         End If
  411.         
  412.         'Reinitialize the loop vars
  413.         finished = False
  414.         cur_obj_count = 1
  415.         index = 1
  416.         Call NewGaugeLoop
  417.  
  418.         'Here we traverse the tree gathering the maximum size box in each level
  419.         While Not ABC.PercentGaugeCancelled And Not finished
  420.             Rem update status bar
  421.             ABC.PercentGaugeValue = CalcPercent()
  422.  
  423.             If cur_obj_count <> 1 Then
  424.                 If OrgChartOptionsDlg.EqualWithinLevels.Value = True Then
  425.                     ShapeList(cur_obj_count).Width = obj_size_level(index, size_cx)
  426.                     ShapeList(cur_obj_count).Height = obj_size_level(index, size_cy)
  427.                 Else    'The object has to be at least as big as the biggest on the next level
  428.                     If OrgChartOptionsDlg.IncreaseMgrSize.Value = True Then
  429.                         If index < num_levels And index > 1 Then
  430.                             If ShapeList(cur_obj_count).Width < obj_size_level(index + 1, size_cx) Then
  431.                                 ShapeList(cur_obj_count).Width = obj_size_level(index + 1, size_cx)
  432.                             End If
  433.                             If ShapeList(cur_obj_count).Height < obj_size_level(index + 1, size_cy) Then
  434.                                 ShapeList(cur_obj_count).Height = obj_size_level(index + 1, size_cy)
  435.                             End If
  436.                         End If
  437.                     End If
  438.                 End If
  439.             End If
  440.             If RelationMap(cur_obj_count, first_child) = 0 Then
  441.                 ShapeRefStack(index) = cur_obj_count
  442.  
  443.                 cur_obj_count = RelationMap(cur_obj_count, next_sibling)
  444.  
  445.                 While cur_obj_count = 0 And index <> 1
  446.                     index = index - 1
  447.                     If index > 1 Then
  448.                         cur_obj_count = ShapeRefStack(index)
  449.                         If cur_obj_count Then
  450.                             cur_obj_count = RelationMap(cur_obj_count, next_sibling)
  451.                         End If
  452.                     End If
  453.                 Wend
  454.             Else
  455.                 ShapeRefStack(index) = cur_obj_count
  456.                 index = index + 1
  457.                 cur_obj_count = RelationMap(cur_obj_count, first_child)
  458.             End If
  459.             If index = 1 Then
  460.                 finished = True
  461.             End If
  462.         Wend
  463.  
  464.        
  465.         'Format the chart *here*
  466.         'start at the top (the "God" object)
  467.  
  468.         ReDim size_branch(req_objs) As Double
  469.         ReDim size_level(req_objs) As Double
  470.         Dim box_spacing_peers As Double
  471.         Dim box_spacing_levels As Double
  472.        ' Dim vertical As Integer
  473.        ' Dim inverted As Integer
  474.         
  475.         
  476.         box_spacing_peers = Val(OrgChartOptionsDlg.BoxSpacing.Text)
  477.         box_spacing_levels = box_spacing_peers * 2
  478.  
  479.         finished = False
  480.         cur_obj_count = 1
  481.         index = 1
  482.         Call NewGaugeLoop
  483.  
  484.         'We're just calculating the sizes that these shapes need so far.
  485.         While Not ABC.PercentGaugeCancelled And Not finished
  486.             Rem update status bar
  487.             ABC.PercentGaugeValue = CalcPercent()
  488.  
  489.             If cur_obj_count <> 1 Then
  490.                 If vertical = True Then
  491.                     If ShapeList(cur_obj_count).Height > size_level(index) Then
  492.                         size_level(index) = ShapeList(cur_obj_count).Height
  493.                     End If
  494.                 Else
  495.                     If ShapeList(cur_obj_count).Width > size_level(index) Then
  496.                         size_level(index) = ShapeList(cur_obj_count).Width
  497.                     End If
  498.                 End If
  499.             End If
  500.             If RelationMap(cur_obj_count, first_child) = 0 Then
  501.                 ShapeRefStack(index) = cur_obj_count
  502.  
  503.                 For counter = 1 To index
  504.                     If vertical = True Then
  505.                         size_branch(ShapeRefStack(counter)) = size_branch(ShapeRefStack(counter)) + ShapeList(cur_obj_count).Width + box_spacing_peers
  506.                     Else
  507.                         size_branch(ShapeRefStack(counter)) = size_branch(ShapeRefStack(counter)) + ShapeList(cur_obj_count).Height + box_spacing_peers
  508.                     End If
  509.                 Next
  510.  
  511.                 cur_obj_count = RelationMap(cur_obj_count, next_sibling)
  512.  
  513.                 While cur_obj_count = 0 And index <> 1
  514.                     index = index - 1
  515.                     If index > 1 Then
  516.                         cur_obj_count = ShapeRefStack(index)
  517.                         If cur_obj_count Then
  518.                             cur_obj_count = RelationMap(cur_obj_count, next_sibling)
  519.                         End If
  520.                     End If
  521.                 Wend
  522.             Else
  523.                 ShapeRefStack(index) = cur_obj_count
  524.                 index = index + 1
  525.                 cur_obj_count = RelationMap(cur_obj_count, first_child)
  526.             End If
  527.             If index = 1 Then
  528.                 finished = True
  529.             End If
  530.         Wend
  531.  
  532.         
  533.         Dim posX As Double
  534.         Dim posY As Double
  535.         Dim newline As Object
  536.  
  537.  
  538.         'I'll have to admit - this is a little hard to follow - but it's BASIC you know, Visual or not
  539.         'Can't do too much about the recursion stuff in BASIC
  540.         
  541.         posX = box_spacing_peers + size_branch(1)
  542.         posY = 0
  543.         mirrorX = box_spacing_peers + size_branch(1)
  544.         mirrorY = box_spacing_levels
  545.         cur_obj_count = 1
  546.         index = 1
  547.         finished = False
  548.  
  549.         For counter = 2 To num_levels
  550.             mirrorY = mirrorY + size_level(counter) + box_spacing_levels
  551.         Next
  552.  
  553.         Call NewGaugeLoop
  554.  
  555.         'This is recursion in disguise....
  556.         'Don't be confused-> X and Y are reversed if this is not vertical
  557.         While Not ABC.PercentGaugeCancelled And Not finished
  558.             Rem update status bar
  559.             ABC.PercentGaugeValue = CalcPercent()
  560.  
  561.             If cur_obj_count <> 1 Then
  562.                 If vertical Then
  563.                     ShapeList(cur_obj_count).CenterX = posX - (size_branch(cur_obj_count) / 2)
  564.                 Else
  565.                     ShapeList(cur_obj_count).CenterY = posX - (size_branch(cur_obj_count) / 2)
  566.                 End If
  567.                 posY = box_spacing_levels
  568.                 For counter = 2 To index - 1
  569.                     posY = posY + size_level(counter) + box_spacing_levels
  570.                 Next
  571.                 If vertical Then
  572.                     If inverted Then
  573.                         ShapeList(cur_obj_count).Bottom = mirrorY - posY
  574.                     Else
  575.                         ShapeList(cur_obj_count).Top = posY
  576.                     End If
  577.                 Else
  578.                     If inverted Then
  579.                         ShapeList(cur_obj_count).Right = mirrorY - posY
  580.                     Else
  581.                         ShapeList(cur_obj_count).Left = posY
  582.                     End If
  583.                 End If
  584.             End If
  585.             
  586.             If RelationMap(cur_obj_count, first_child) = 0 Then
  587.                 posX = posX - size_branch(cur_obj_count)
  588.                  
  589.                 cur_obj_count = RelationMap(cur_obj_count, next_sibling)
  590.  
  591.                 While cur_obj_count = 0 And index <> 1
  592.                     index = index - 1
  593.                     If index > 1 Then
  594.                         cur_obj_count = ShapeRefStack(index)
  595.                         If cur_obj_count Then
  596.                             cur_obj_count = RelationMap(cur_obj_count, next_sibling)
  597.                         End If
  598.                     End If
  599.                 Wend
  600.             Else
  601.                 ShapeRefStack(index) = cur_obj_count
  602.                 index = index + 1
  603.                 cur_obj_count = RelationMap(cur_obj_count, first_child)
  604.  
  605.             End If
  606.             
  607.             If index = 1 Then
  608.                 finished = True
  609.             End If
  610.         Wend
  611.  
  612.         Call NewGaugeLoop
  613.         Junk = CalcPercent()  ' since we're skipping an object in this loop
  614.        
  615.         For counter = 2 To req_objs
  616.             If ABC.PercentGaugeCancelled Then Exit For
  617.             ABC.PercentGaugeValue = CalcPercent()
  618.             
  619.             If RelationMap(counter, parent) > 1 Then
  620.                 If vertical Then
  621.                     If inverted Then
  622.                         Set newline = Chart.DrawLine(ShapeList(RelationMap(counter, parent)), ShapeList(counter), 0, 2)
  623.                     Else
  624.                         Set newline = Chart.DrawLine(ShapeList(RelationMap(counter, parent)), ShapeList(counter), 2, 0)
  625.                     End If
  626.                 Else
  627.                     If inverted Then
  628.                         Set newline = Chart.DrawLine(ShapeList(RelationMap(counter, parent)), ShapeList(counter), 3, 1)
  629.                     Else
  630.                         Set newline = Chart.DrawLine(ShapeList(RelationMap(counter, parent)), ShapeList(counter), 1, 3)
  631.                     End If
  632.                 End If
  633.  
  634.                 newline.Line_.StemWidth = 3
  635.                 newline.Line_.DestArrowStyle = 0
  636.                 newline.Line_.SourceArrowStyle = 0
  637.                 newline.Line_.Color = ABC.BLUE
  638.             End If
  639.         Next
  640.  
  641.         DoCreateOrgChart = 1
  642.     Else
  643.         DoCreateOrgChart = 0
  644.     End If
  645.  
  646. DoCreateAbort:
  647.  
  648.     Chart.View = 2
  649.     Chart.NoRepaint = False
  650.     Chart.Repaint
  651.  
  652.     ABC.HidePercentGauge
  653.  
  654. End Function
  655.  
  656. Private Sub Form_Load()
  657.     Set ABC = CreateObject("ABCFlow.application")
  658.     ABC.Visible = True
  659.     OrgChartTextFileEdit = LCase(App.Path + "\ORGCHRT1.TXT")
  660.     Load OrgChartOptionsDlg
  661.     ABC.RegisterEvent ABC1, APPNAME, "AppQuitNOTIFY"
  662. End Sub
  663.  
  664. Private Sub Form_Unload(Cancel As Integer)
  665.     Unload OrgChartOptionsDlg
  666. End Sub
  667.  
  668. Private Function FormatOrgString(ByVal OrgString As String) As String
  669.     Dim index As Integer
  670.     Dim len_str As Integer
  671.     Dim test_ascCode As Integer
  672.     Dim in_quotes As Integer
  673.     Dim FormattedStr As String
  674.     
  675.     index = 1
  676.     in_quotes = False
  677.     len_str = Len(OrgString)
  678.     FormattedStr = ""
  679.  
  680.     While index < (len_str + 1)
  681.         test_ascCode = Asc(Mid$(OrgString, index))
  682.         If test_ascCode = 34 Then
  683.             in_quotes = Not in_quotes
  684.         ElseIf in_quotes Then
  685.             FormattedStr = FormattedStr + Chr$(test_ascCode)
  686.         ElseIf test_ascCode = 44 Then: Rem comma
  687.             FormattedStr = FormattedStr + Chr$(13)
  688.         End If
  689.  
  690.         index = index + 1
  691.         
  692.     Wend
  693.     FormatOrgString = FormattedStr
  694.  
  695. End Function
  696.  
  697. Private Function GetNumLines(test_str As String) As Integer
  698.     Dim len_str As Integer
  699.     Dim index As Integer
  700.     Dim in_line_feed As Integer
  701.     Dim test_ascCode As Integer
  702.     Dim total_lines As Integer
  703.  
  704.     in_line_feed = True
  705.     index = 1
  706.     len_str = Len(test_str)
  707.     total_lines = 0
  708.  
  709.     While index < len_str + 1
  710.         test_ascCode = Asc(Mid$(test_str, index))
  711.         If test_ascCode = 13 Or test_ascCode = 10 Then
  712.             If Not in_line_feed Then
  713.                 total_lines = total_lines + 1
  714.                 in_line_feed = True
  715.             End If
  716.         Else
  717.             in_line_feed = False
  718.         End If
  719.         index = index + 1
  720.     Wend
  721.     GetNumLines = total_lines
  722.  
  723. End Function
  724.  
  725. Private Sub NewGaugeLoop()
  726.     LoopIter = 0
  727.     FormatIter = FormatIter + 1
  728. End Sub
  729.  
  730. Private Sub OKBtn_Click()
  731.     OrgChartDlg.WindowState = 1 ' iconize form
  732.     OrgChartDlg.Refresh
  733.     success = DoCreateOrgChart(OrgChartTextFileEdit.Text)
  734. End Sub
  735.  
  736. Private Sub OptionsBtn_Click()
  737.     OrgChartDlg.Enabled = False
  738.     OrgChartOptionsDlg.Show
  739. End Sub
  740.  
  741. Private Sub OrgChartTextFileEdit_Change()
  742.     Call ValidateFilename
  743. End Sub
  744.  
  745. Private Sub ValidateFilename()
  746.    On Error Resume Next
  747.    Attr = GetAttr(OrgChartTextFileEdit)
  748.    If Err Then
  749.         OKBtn.Enabled = False
  750.    Else
  751.         OKBtn.Enabled = True
  752.    End If
  753. End Sub
  754.  
  755.